<template>
  <div class="error-page">
    <div class="error-content">
      <el-result
        :icon="statusIcon"
        :title="statusTitle"
        :sub-title="subTitle"
      >
        <template #extra>
          <el-button type="primary" @click="goHome">返回首页</el-button>
          <el-button @click="goBack">返回上一页</el-button>
        </template>
      </el-result>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ErrorPage',
  props: {
    status: {
      type: Number,
      default: 404
    }
  },
  computed: {
    statusIcon() {
      const statusMap = {
        403: 'warning',
        404: 'error',
        500: 'error'
      }
      return statusMap[this.status] || 'error'
    },
    statusTitle() {
      const titleMap = {
        403: '403',
        404: '404',
        500: '500'
      }
      return titleMap[this.status] || '错误'
    },
    subTitle() {
      const subtitleMap = {
        403: '抱歉，您无权访问此页面',
        404: '抱歉，您访问的页面不存在',
        500: '抱歉，服务器出错了'
      }
      return subtitleMap[this.status] || '发生了一些错误'
    }
  },
  methods: {
    goHome() {
      this.$router.push('/')
    },
    goBack() {
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="scss" scoped>
.error-page {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background-color: #f5f7fa;
  
  .error-content {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    text-align: center;
  }
}
</style> 